﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace FlyOut
{
    public sealed partial class FlyOut : UserControl
    {
        /// <summary>
        /// Instancia do popup que sera usado para controle
        /// </summary>
        Popup _popup;

        /// <summary>
        /// Contructor
        /// </summary>
        /// <param name="popup">Intanci do PopUp, usado para controle</param>
        public FlyOut(Popup popup)
        {
            _popup = popup;
        }

        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        /// <summary>
        /// Fecha o FlyOut
        /// </summary>
        public void Close()
        {
            _popup.IsOpen = false;
        }


        /// <summary>
        /// Adciona um UserControl o flyout
        /// </summary>
        /// <param name="usercontrol">O UserControl</param>
        public void Add(UserControl usercontrol)
        {
            if (gridAdd.Children.Count == 0)
            {
                gridAdd.Children.Add(usercontrol); 
            }
        }
    }
}
